package cn.ellacat.game.guess;

/**
 * @author wjc133
 */
public class ConsoleColorUtils {

    public static String getConsoleStr(final String text, final Style style, final Color front) {
        return "\033[" + front.getFront() + ";" + style.getCode() + "m"
                + text + "\033[0m";
    }

    public static String getConsoleStr(final String text, final Style style, final Color front, final Color back) {
        return "\033[" + front.getFront() + ";" + back.getBack() + ";" + style.getCode() + "m"
                + text + "\033[0m";
    }


    public enum Style {
        EMPTY(0),
        BOLD(1),
        UNDERLINE(4),
        REVERT(7);

        private final int code;

        Style(final int code) {
            this.code = code;
        }

        public int getCode() {
            return this.code;
        }
    }

    public enum Color {
        WHITE(30),
        RED(31),
        GREEN(32),
        YELLOW(33),
        BLUE(34),
        /**
         * 紫色
         */
        PURPLE(35),
        /**
         * 浅蓝
         */
        LIGHT_BLUE(36),
        GRAY(37);

        private final int code;

        Color(final int code) {
            this.code = code;
        }

        public int getFront() {
            return this.code;
        }

        public int getBack() {
            return this.code + 10;
        }

        public int getHighLight() {
            return this.code + 60;
        }
    }
}
